<template>
  <div>
    <el-tree
      :data="menus"
      :props="defaultProps"
      
      :expand-on-click-node="false"
      @node-click="nodeClick"
    >
    </el-tree>
  </div>
</template>

<script>
export default {
  data() {
    return {
      menus: [],
      expandKey: [],
      defaultProps: {
        children: "children",
        label: "name",
      },
    };
  },
  methods: {
      nodeClick(data,node,component){
          console.log("结点被点击了...",data,node,component);
          this.$emit("tree-node-click",data,node,component);

      },
    getCategroyData() {
      this.$http({
        url: this.$http.adornUrl("/product/category/list/tree"),
        method: "get",
      }).then(({ data }) => {
        console.log("成功得到數據", data);

        this.menus = data.data;
      });
    },
  },
  created() {
      this.getCategroyData();
  },
};
</script>

<style>
</style>